/*
 *  carAgent.h
 *  
 *
 *  Created by Adam White on 24/02/06.
 *  Copyright 2006 __MyCompanyName__. All rights reserved.
 *
 */
#ifndef AC_HEADER
#define AC_HEADER
 #include <iostream>
#include "tiles.h"
#include "stdio.h"
#include "stdlib.h"
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#include <rlglue/Agent_common.h>
#include <rlglue/utils/C/RLStruct_util.h>
#include <rlglue/utils/C/TaskSpec_Parser.h>

// RL glue agent methods 
void agent_init(const char* _ts); 
const action_t* agent_start(const observation_t* o); 
const action_t *agent_step(double reward, const observation_t *this_observation); 
void agent_end(double reward); 
void agent_cleanup(); 
const char* agent_message(const char* inMessage);



void LoadF(double* o);                                                 // compute features new state
void LoadQ(); 
void SetV();  
int choose_action();
float actor_policy_bottom();
void ClearTrace(int f);                          // clear or zero-out trace, if any, for given feature
void ClearExistentTrace(int f, int loc);         // clear trace at given location in list of nonzero-traces
void ClearTrace_g(int f);                          // clear or zero-out trace, if any, for given feature
void ClearExistentTrace_g(int f, int loc);         // clear trace at given location in list of nonzero-traces
void DecayTraces(float decay_rate);              // decay all nonzero traces
void SetTrace(int f, float new_trace_value);     // set trace to given value
void IncreaseMinTrace();                         // increase minimal trace value, forcing more to 0, making room for new ones
void SetTrace_g(int f, float new_trace_value);     // set trace to given value
void IncreaseMinTrace_g(); 



//util function
template < typename T >
T **Allocate2DArray( int nRows, int nCols); 
template < typename T >
void Free2DArray(T** Array); 



#endif 

